package com.pzr.soccer.handler;

import com.pzr.soccer.model.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author pzr
 * @date:2021-12-13-15:11
 * @Description:
 **/
@ControllerAdvice
@Slf4j
@Order
public class CrawlerGlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R<Object> handleGeneralException(Exception exception) {
        log.warn("error occurred :" + exception.getCause().getMessage());
        return R.fail("error occurred,stop task!  error :" + exception.getCause().getMessage());
    }
}
